<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript">
        window.onload = function() {

            var btnObj = document.getElementById("myButton");

            btnObj.onclick = function() {

                // 获取所有的name为myCheck的所有input
                var cbArrsObj = document.getElementsByName("myCheck");
                var count = 0;
                for (var i = 0; i < cbArrsObj.length; i++) {

                    var cdObj = cbArrsObj[i];

                    if (cdObj.checked) {
                        count++;
                    }
                }
                alert("复选框的个数是: " + count);
            }
        }
    </script>
</head>

<body>
    <input type="checkbox" name="myCheck" />
    <input type="checkbox" name="myCheck" checked="checked" />
    <input type="checkbox" name="myCheck" />
    <input type="checkbox" name="myCheck" />
    <input type="checkbox" name="myCheck" />
    <input type="checkbox" name="myCheck" />

    <input type="button" id="myButton" value="统计" />
</body>

</html>